<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script type="text/javascript">
        function Person(name,age)
        {
            this.name=name;
            this.age=age;
        }
        //通过原型函数添加属性
        Person.prototype.setName=function(name)
        {
            this.name=name;
        };
        //通过构造函数创建新对象
        var person1=new Person("Tom",23);
        var person2=new Person("Jack",24);
        console.log(person1);
        console.log(person2);
        console.log(person1.__proto__.setName);
        person1.name="Seven";
        console.log(person1);
    </script>
</head>
<body>
    <!--
        方式六：构造函数+原型的组合模式
        套路：自定义构造函数，属性在函数中初始化，方法添加到原型上
        适用场景：需要创建多个类型确定的对象
    -->
</body>
</html>